refactor(sui-indexer): rename redeem Solved status to Signing#332
Merged
refactor(sui-indexer): rename redeem Solved status to Signing#332
Conversation
Signed-off-by: Vu Vo <vu.voth@gmail.com>
Contributor
Reviewer's GuideThis PR aligns the redeem lifecycle with a new "signing" status by renaming the previous "solved" status across the indexer service, storage layer, handler, scheduler, and tests, and updating the processing flow to operate on redeems in the signing state. Sequence diagram for the redeem signing flowsequenceDiagram
actor Cron
participant Indexer as runRedeemSolver
participant Service as RedeemService
participant Storage as D1Storage
participant Handler as SuiEventHandler
Cron->>Indexer: Trigger redeem solver
Indexer->>Service: processPendingRedeems()
Indexer->>Service: solveReadyRedeems()
Service-->>Indexer: solved redeems ready
Indexer->>Service: processSigningRedeems()
Service->>Storage: getSigningRedeems()
Storage-->>Service: RedeemRequestWithInputs[]
loop for each signing redeem
Service->>Service: processSolvedRedeem(req)
Service->>Service: makeSigning(req)
Service->>Storage: markRedeemSigning(redeemId)
end
Handler->>Handler: handleSolvedRedeem(SolvedEventRaw)
Handler->>Storage: upsertRedeemInputs(redeemId, utxoIds, dwalletIds)
Handler->>Storage: markRedeemSigning(redeemId)
Storage-->>Handler: status updated to Signing
Class diagram for updated redeem signing lifecycleclassDiagram
class RedeemStatusEnum {
<<enumeration>>
Pending
Proposed
Signing
Signed
}
class D1Storage {
+markRedeemProposed(redeemId number, utxoIds number[], lockTimeMs number) Promise~void~
+markRedeemSigning(redeemId number) Promise~void~
+getSigningRedeems() Promise~RedeemRequestWithInputs[]~
+upsertRedeemInputs(redeemId number, utxoIds number[], dwalletIds string[]) Promise~void~
}
class RedeemService {
+processPendingRedeems() Promise~void~
+solveReadyRedeems() Promise~void~
+processSigningRedeems() Promise~void~
+broadcastReadyRedeems() Promise~void~
-processSolvedRedeem(req RedeemRequestWithInputs) Promise~void~
-makeSigning(req RedeemRequestWithInputs) Promise~void~
-storage D1Storage
}
class SuiEventHandler {
+handle(event any) Promise~void~
-handleSolvedRedeem(e SolvedEventRaw) Promise~void~
-storage D1Storage
}
RedeemService --> D1Storage : uses
SuiEventHandler --> D1Storage : uses
D1Storage --> RedeemStatusEnum : sets_status
Flow diagram for updated runRedeemSolver pipeline with signing statusflowchart TD
A[runRedeemSolver] --> B[processPendingRedeems]
A --> C[solveReadyRedeems]
C --> D[processSigningRedeems]
D --> E[getSigningRedeems from D1Storage]
D --> F[processSolvedRedeem and makeSigning]
F --> G[markRedeemSigning in D1Storage]
A --> H[broadcastReadyRedeems]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- There are several spelling inconsistencies for the new status (e.g.,
markRedeemSinging,sinnings) that should be corrected toSigningto keep method/variable names consistent and avoid confusion. - The log context in
makeSigning(formerlysolveRequest) still references the old naming pattern; double-check logmsgandmethodfields throughout to keep terminology aligned with the newSigningstatus.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- There are several spelling inconsistencies for the new status (e.g., `markRedeemSinging`, `sinnings`) that should be corrected to `Signing` to keep method/variable names consistent and avoid confusion.
- The log context in `makeSigning` (formerly `solveRequest`) still references the old naming pattern; double-check log `msg` and `method` fields throughout to keep terminology aligned with the new `Signing` status.
## Individual Comments
### Comment 1
<location> `packages/sui-indexer/src/storage.ts:333-337` </location>
<code_context>
}
- async markRedeemSolved(redeemId: number): Promise<void> {
+ async markRedeemSinging(redeemId: number): Promise<void> {
try {
await this.db
.prepare("UPDATE nbtc_redeem_requests SET status = ? WHERE redeem_id = ?")
- .bind(RedeemRequestStatus.Solved, redeemId)
+ .bind(RedeemRequestStatus.Signing, redeemId)
.run();
} catch (error) {
</code_context>
<issue_to_address>
**issue (typo):** The method name `markRedeemSinging` appears to be a typo and should probably be `markRedeemSigning`.
This looks like an accidental misspelling given that the status and related code use `Signing`. Please rename the method to `markRedeemSigning` and update all its call sites for consistency and clarity.
Suggested implementation:
```typescript
async markRedeemSigning(redeemId: number): Promise<void> {
```
1. Search the entire codebase for `markRedeemSinging` and rename all call sites to `markRedeemSigning`.
2. If this method is part of a public interface (e.g., exported class), ensure any tests, mocks, or type declarations referencing `markRedeemSinging` are also updated accordingly.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Signed-off-by: Vu Vo <vu.voth@gmail.com>
Contributor
There was a problem hiding this comment.
Hey - I've found 2 issues, and left some high level feedback:
- In
RedeemService.processSigningRedeems, the local variable is namedsinningsinstead ofsignings, which makes the code harder to read; consider renaming it tosignings(or similar) for clarity. - Now that the status is
Signing, consider renamingprocessSolvedRedeemand the related log messages that still say "solved" to use "signing" terminology so the method names and logs consistently reflect the new lifecycle state.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `RedeemService.processSigningRedeems`, the local variable is named `sinnings` instead of `signings`, which makes the code harder to read; consider renaming it to `signings` (or similar) for clarity.
- Now that the status is `Signing`, consider renaming `processSolvedRedeem` and the related log messages that still say "solved" to use "signing" terminology so the method names and logs consistently reflect the new lifecycle state.
## Individual Comments
### Comment 1
<location> `packages/sui-indexer/src/redeem-service.ts:55-56` </location>
<code_context>
- async processSolvedRedeems() {
+ async processSigningRedeems() {
// NOTE: here we are processing only 50 redeems every minute (every cron), we are not
// looping thought all the solved redeems to avoid cloudflare timeout, since we are
// already waiting for ika to sign, when calling ikaSdk.getPresignInParicularState
- const solved = await this.storage.getSolvedRedeems();
</code_context>
<issue_to_address>
**nitpick (typo):** Update the comment to reflect the new `signing` status and fix the minor typo.
This still mentions "solved redeems" even though the function now handles `signing` redeems. Please update the phrase to "signing redeems" and correct the typo "thought" → "through" to match the new flow and fix the wording.
```suggestion
// NOTE: here we are processing only 50 redeems every minute (every cron), we are not
// looping through all the signing redeems to avoid cloudflare timeout, since we are
```
</issue_to_address>
### Comment 2
<location> `packages/sui-indexer/src/handler.ts:93-94` </location>
<code_context>
- await this.storage.markRedeemSolved(Number(e.redeem_id));
+ await this.storage.markRedeemSigning(Number(e.redeem_id));
logger.info({
msg: "Marked redeem as solved and added inputs",
</code_context>
<issue_to_address>
**suggestion:** Log message still says "solved" although the status is now set to `Signing`.
Since this handler now calls `markRedeemSigning`, please update the log text to say `signing` instead of `solved` to keep status transitions clear in the logs.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Signed-off-by: Vu Vo <vu.voth@gmail.com>
Contributor
Author
|
@sourcery-ai title |
Co-authored-by: sczembor <43810037+sczembor@users.noreply.github.com> Signed-off-by: vuvoth <vu.voth@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes: #266
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!to the type prefix if API or client breaking changeCHANGELOG.mdSummary by Sourcery
Align redeem request lifecycle to use a new Signing status and associated processing flow instead of Solved.
Enhancements:
Tests: